import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:part_time_job_pro/common/index.dart';
import 'logic.dart';

class OfferPage extends StatelessWidget {
  OfferPage({Key? key}) : super(key: key);

  //路由地址
  static const String routeName = "/offer";
  final logic = Get.find<OfferLogic>();
  final state = Get.find<OfferLogic>().state;

  @override
  Widget build(BuildContext context) {
    return GetBuilder<OfferLogic>(builder: (logic) {
      return Scaffold(
        appBar: PreferredSize(
            preferredSize: Size.fromHeight(topBarbackHeight.r),
            child: buildCustomAppBar(state.tabBarList)),
        body: TabBarView(
          controller: logic.tabController,
          //physics: NeverScrollableScrollPhysics(),
          children: state.mainIndexStackPages,
        ),
      );
    });
  }

  //自定义appbar
  Widget buildCustomAppBar(List tabsList) {
    return AppBar(
        centerTitle: true,
        elevation: 0,
        backgroundColor: AppColor.norWhite01Color,
        actions: [
          IconButton(
              icon: Image.asset("assets/images/icon/icon_msg.png"),
              color: AppColor.norMainThemeColors,
              alignment: Alignment.centerRight,
              padding: const EdgeInsets.fromLTRB(0, 4, 15, 5),
              onPressed: () {
                LogUtil.e("click menu button!!!");
              })
        ],
        title: TabBar(
          controller: logic.tabController,
          isScrollable: true,
          indicatorWeight: 2,
          labelColor: AppColor.norMainThemeColors,
          indicatorSize: TabBarIndicatorSize.label,
          indicatorColor: AppColor.norMainThemeColors,
          unselectedLabelColor: Colors.black87,
          indicatorPadding: EdgeInsets.only(bottom: 1.r),
          labelStyle: TextStyle(
              fontSize: 14.sp,
              color: Colors.white,
              fontWeight: FontWeight.w600),
          unselectedLabelStyle:
              TextStyle(fontWeight: FontWeight.normal, fontSize: 14.sp),
          labelPadding: const EdgeInsets.fromLTRB(10, 6, 10, 0),
          tabs: tabsList.map((item) => Tab(text: item['name'])).toList(),
        ));
  }
}
